# -*- coding: utf-8 -*-
"""
@Time : 2023/6/11 19:10
@Author : Gremore
@File : plan
@Des: 
"""

from datetime import datetime
from sqlalchemy import Column, String, INT, DATETIME, SMALLINT, func, Boolean
from tsim.models import Base
from tsim.commons.enums import PermissionEnum
from tsim.routers.plan.request_model import CreatePlanBody

class PlanTab(Base):
    __tablename__ = "plan_tab"

    id = Column(INT, primary_key=True, comment="主键id")
    title = Column(String(128), nullable=True, comment="标题")
    description = Column(String(512), nullable=True, default="", comment="描述")
    type = Column(String(64), nullable=True, default="", comment="类型")
    tags = Column(String(64), nullable=True, default="", comment="标签")
    status = Column(String(64), nullable=True, default="", comment="状态")
    priority = Column(SMALLINT, default=0, comment="优先级")
    is_delete = Column(Boolean, nullable=False, default=False, comment="是否删除")
    create_time = Column(DATETIME, nullable=False, comment="创建时间")
    update_time = Column(DATETIME, onupdate=func.now(), nullable=False, comment="更新时间")

    def __init__(self, form: CreatePlanBody):
        self.title = form.title
        self.description = form.description
        self.is_delete = False
        self.create_time = datetime.now()
        self.update_time = datetime.now()